package com.example.reeman.ymfacedemo.utils;

import android.util.Log;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by xiaoluo on 2017/3/9.
 */
public class CameraUtils {
    public static boolean checkUsb() {
        try {
            // 获得外接USB输入设备的信息
            Process p = Runtime.getRuntime()
                    .exec("cat /proc/bus/input/devices");
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    p.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                String deviceInfo = line.trim();
                Log.v("CameraUtils", "usb info: " + deviceInfo);
                if (deviceInfo.contains("Camera")) {
                    return true;
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
